﻿/*global angular*/
/*jslint unparam:true*/
(function () {
    'use strict';
    var app = angular.module('app');
    app.factory('providerService', ['$http', '$q', function ($http, $q) {
        function getByDepartment(id) {
            var deferred = $q.defer();
            $http.get('../api/Providers/GetByDepartmentLazy', {
                params: { id: id}
            }).
                success(function (data) {//, status, headers, config
                    deferred.resolve(data);
                }).
                error(function (data, status) {//, headers, config
                    deferred.reject(status);
                });
            return deferred.promise;
        }

        var service = {
           getByDepartment: getByDepartment
        };

        return service;
    }]);
}());